package SortTable;

//简单选择排序
public class SelectionSort {
    //选择对应序列中最小的
    public static int selectMin(int[] arr,int start,int end) {
        int min = start;
        for (int i = start; i <= end; i++) {
            if (arr[i] <= arr[min]) {
                min = i;
            }
        }
        return min;
    }
    public static void sort(int[] arr){
        for (int i=0;i<=arr.length-1;i++){
            int j = selectMin(arr, i, arr.length - 1);
            if (j!=i){
                int temp=arr[i];
                arr[i]=arr[j];
                arr[j]=temp;
            }
        }
    }
    public static void main(String[] args) {
        int arr[]={4,2,6,7,94,5,90};
        sort(arr);
        for (int i = 0; i <arr.length-1 ; i++) {
            System.out.println(arr[i]);
        }
    }
}
